import {atom} from 'recoil';
import { UserResponse } from 'pb/proto/auth/query_pb';

export interface RootState {
    locale: string
    localeText?: string
    scale?: string
};

export interface ConditionState {
    loading: boolean
    scale?: string
};

export const RootProivder = atom<RootState>({
    key: 'rootState',
    default: {
        locale: 'zh-CN',
        localeText: '简体中文', 
        scale: '1'
    }
});

export const ConditionProivder = atom<ConditionState>({
    key: 'conditionState',
    default: {
        loading: false,
    }
});

export interface ConfigState {
    isLogin: boolean
    isSign: boolean
    isAuth: boolean
    options?: any
};

export const ConfigProvider = atom<ConfigState>({
    key: 'configState',
    default: {
        isLogin: false,
        isSign: false,
        isAuth: true
    }
});

export interface UserState extends UserResponse {
    expiryed?: number
    isLogin?: boolean
}

export const userInfoProvider = atom<UserState>({
    key: "userInfoState",
    default: {
        $typeName: "auth.UserResponse"
    }
})